package com.example.xinli.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.xinli.domain.entity.Record;
import com.example.xinli.dao.RecordMapper;
import com.example.xinli.service.IRecordService;
import com.example.xinli.domain.vo.ResponseBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class RecordServiceImpl extends ServiceImpl<RecordMapper, Record> implements IRecordService {

    @Autowired
    private RecordMapper recordMapper;

    @Override
    public ResponseBean getAllUserRecord(String userId) {
        QueryWrapper<Record> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        List<Record> recordList = recordMapper.selectList(queryWrapper);
        return ResponseBean.success(recordList);
    }

    @Override
    public ResponseBean getUserRecord(String userId, int interId) {
        QueryWrapper<Record> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        queryWrapper.eq("inter_id", interId);
        Record record = recordMapper.selectOne(queryWrapper);
        return ResponseBean.success(record);
    }
}

